<template>
  <el-row :gutter="20" class="tac">
    <el-col :span="4">
      <sticky :sticky-top="70">
        <div style="text-align: center">
          <router-link class="inlineBlock" to="/blog/add">
            <el-button type="primary" round style="width: 80%">
              发布
            </el-button>
          </router-link>
        </div>
        <el-menu
          :router="true"
          :unique-opened="true"
          :default-active="activeName"
          class="el-menu-vertical-demo">
          <el-submenu index="manage">
            <template slot="title">
              <i class="el-icon-s-marketing"/>
              <span style="font-size: medium">管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="article">内容管理</el-menu-item>
              <el-menu-item v-if="hasPerm('problem.add')" index="problem">试题管理</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="data">
            <template slot="title">
              <i class="el-icon-s-data"/>
              <span style="font-size: medium">数据</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="works">作品数据</el-menu-item>
              <el-menu-item index="fans">粉丝数据</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="tools">
            <template slot="title">
              <i class="el-icon-s-tools"/>
              <span style="font-size: medium">工具</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="tools1">待定</el-menu-item>
              <el-menu-item index="tools2">待定</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </sticky>
    </el-col>
    <el-col :span="20">
      <slot/>
    </el-col>
  </el-row>
</template>

<script>

import Sticky from '@/components/Sticky'

export default {
  name: 'ManageSidebar',
  components: { Sticky },

  computed: {
    activeName() {
      const path = this.$route.path
      return path.substring(path.lastIndexOf('/') + 1)
    }
  }
}
</script>
